package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dto.ElderlyDetailedPageDTO;
import com.example.demo.mapper.ElderlyDetailOkMapper;
import com.example.demo.pojo.ElderlyDetailedOk;
import com.example.demo.service.ElderlyBasicOkService;
import com.example.demo.service.ElderlyDetailedOkService;
import com.example.demo.service.ElderlyDetailedService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ElderlyDetailedOkServiceImpl extends ServiceImpl<ElderlyDetailOkMapper, ElderlyDetailedOk> implements ElderlyDetailedOkService {

    @Override
    public List<ElderlyDetailedOk> getElderlyDetailOk(ElderlyDetailedPageDTO elderlyDetailedPageDTO) {
        // 获取superior_id是我的用户的全部id

        // 获取老人的user_id是 我的全部用户的id
        Long id = elderlyDetailedPageDTO.getId();
        Integer pageSize = elderlyDetailedPageDTO.getPageSize();
        Integer page = elderlyDetailedPageDTO.getPage();

        Page<ElderlyDetailedOk> p = Page.of(page, pageSize);
        p.addOrder(new OrderItem("id", false));
        lambdaQuery()
                .eq(ElderlyDetailedOk::getElderlyId, id)
                .page(p);
        return p.getRecords();
    }
}
